package com.wing.cabinet.model.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * 暂存柜存刀/取刀;存/取维修/回收刀明细
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("cab_storage_inventory_inout_detail")
public class StorageInventoryInoutDetail extends BaseEntity<StorageInventoryInoutDetail> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum OperationType implements IEnum<Integer> {

        /**
        * 存刀
        */
        in(1,"存刀"),
        /**
        * 取刀
        */
        out(2,"取刀");

        private int code;
        private String desc;

        OperationType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static OperationType jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (OperationType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }


    }

    public enum BusinessType implements IEnum<Integer> {

        /**
        * 暂存
        */
        temp(1,"暂存"),
        /**
        * 维修
        */
        repair(2,"维修"),
        /**
        * 回收
        */
        recycle(3,"回收"),
        /**
         * 格子柜上货
         */
        exhibit(4,"格子柜上货"),
        /**
         * 报失
         */
        loss(5,"报失"),
        /**
         * 格子柜上货
         */
        unload(6,"格子柜下货");

        private int code;
        private String desc;

        BusinessType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static BusinessType jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (BusinessType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }

    }


    public enum BusinessTypeChecked implements IEnum<Integer> {

        /**
         * 暂存
         */
        temp(1,"暂存"),
        /**
         * 维修
         */
        repair(2,"维修"),
        /**
         * 回收
         */
        recycle(3,"回收");

        private int code;
        private String desc;

        BusinessTypeChecked(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static BusinessTypeChecked jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (BusinessTypeChecked item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    public enum LoadingType implements IEnum<Integer> {

        /**
         * 暂存
         */
        temp(0,"暂存"),
        /**
         * 格子柜
         */
        grid(1,"格子柜");

        private int code;
        private String desc;

        LoadingType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static LoadingType jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (LoadingType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }


    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 暂存柜存刀id
     */
    private Long inoutId;

    /**
     * 柜子id
     */
    private Long cabId;

    /**
     * sku id
     */
    private Long skuId;

    /**
     * 数量
     */
    private Integer quantity;

    /**
     * 企业id
     */
    private Long companyId;

    /**
     * 货道id
     */
    private Long spaceId;

    /**
     * 操作类型
     */
    private OperationType operationType;

    /**
    * 操作类型描述
    */
    @TableField(exist = false)
    private String operationTypeDesc;

    public String getOperationTypeDesc() {
        return operationType == null ? null : operationType.getDesc();
    }

    /**
     * 业务类型
     */
    private BusinessType businessType;

    /**
     * 业务类型
     */
    private BusinessTypeChecked businessTypeChecked;

    /**
    * 业务类型描述
    */
    @TableField(exist = false)
    private String businessTypeDesc;

    public String getBusinessTypeDesc() {
        return businessType == null ? null : businessType.getDesc();
    }

    /**
     * 柜子编号
     */
    private String cabCode;

    /**
     * sku 编号
     */
    private String skuCode;

    /**
     * 货道编号
     */
    private String spaceCode;

    /**
     * 当前库存
     */
    private Integer quantityCurrent;

    /**
     * 变动后库存
     */
    private Integer quantityAfter;


    /**
     * 签收数量
     */
    private Integer quantitySign;

    /**
     * 维修价格
     */
    private BigDecimal repairPrice;

    public enum IsSyns implements IEnum<Integer> {

        /**
         * 未同步
         */
        no(0,"未同步"),
        /**
         * 已同步
         */
        yes(1,"已同步");

        private int code;
        private String desc;

        IsSyns(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }
    private StorageInventoryInoutDetail.IsSyns isSyns;

    private String labelCode;

    private Integer quantityChecked;

    private Integer operationTypeChecked;

    private Integer quantityCurrentChecked;

    private Integer quantityAfterChecked;

    private String creatorNickname;

    private BigDecimal price;

    private BigDecimal total;

    /**
     * 企业编码
     */
    private String enterpriseCode;
    @TableField(exist = false)
    private String inoutUniqCode;


    /**
     * 同步时间
     */
    @JsonFormat(timezone = "GMT+8" , pattern = "yyyy-MM-dd HH:mm:ss" )
    private LocalDateTime synsTime;

    private LoadingType loadingType;

    private Long categoryId;

    private Integer quantitySingleCabCurrent;

    private Integer quantitySingleCabAfter;

    private Integer quantityCabCurrent;

    private Integer quantityCabAfter;

    private Integer quantityUserCurrent;

    private Integer quantityUserAfter;


    private Long storageInventoryUserId;


    private Integer settingTime;


    private Integer remainingTime;

    private Integer useTime;

    /**
     * 寿命单位  1：小时/ 2：次数
     */
    private LifeUnit lifeUnit;

    /**
     * 1：分钟/ 2：个数
     */
    public enum LifeUnit implements IEnum<Integer> {

        /**
         * 分钟
         */
        minute(1,"分钟"),
        /**
         * 个数
         */
        number(2,"个数");

        private int code;
        private String desc;

        LifeUnit(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
        @JsonCreator
        public static LifeUnit jsonCreator(String name) {
            if (org.apache.commons.lang.StringUtils.isNotBlank(name)) {
                for (LifeUnit item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }
    /**
     * 渠道编号
     */
    private String channelCode;

    private String mainCabCode;

    private Integer quantityPack;

    private Integer quantityPackUnit;

    private Long packId;

    private String packName;

    private String unitName;

    private Integer quantityPackCurrent;

    private Integer quantityPackAfter;


    private Integer quantityPackSingleCabCurrent;

    private Integer quantityPackSingleCabAfter;


    private Integer quantityPackCabCurrent;

    private Integer quantityPackCabAfter;
}
